<cfcomponent output="false" displayname="userGateway" hint="I am a user gateway.">

	<cffunction name="init" access="public" returntype="any" output="false">
		<cfargument name="dsn" required="yes" type="string">
		<cfset variables.dsn = arguments.dsn>
		<cfreturn this>
	</cffunction>

	<cffunction name="getUsers" access="public" returntype="query" output="false">
		<cfargument name="last_name" required="no" type="string" default="">
		<cfargument name="email" required="no" type="string" default="">
		<cfargument name="middlename" required="no" type="string" default="">
		<cfset var qUsers = 0>
		<cfquery name="qUsers" datasource="#variables.dsn#">
		SELECT userid, first_name, last_name, email, middlename
		FROM users
		WHERE (1=1)
			<cfif arguments.last_name neq "">AND last_name = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.last_name#"
				null="#yesnoformat(len(arguments.last_name) eq 0)#" maxlength="50"></cfif>
			<cfif arguments.email neq "">AND email = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.email#"
				null="#yesnoformat(len(arguments.email) eq 0)#" maxlength="100"></cfif>
		</cfquery>
		<cfreturn qUsers>
	</cffunction>

</cfcomponent>